/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.gov.cemaden.library.model.smp;

import br.gov.cemaden.library.model.BaseEntity;
import java.io.Serializable;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

/**
 *
 * @author Simone Santos
 */
@Entity
@Table(name = "smp_whosys_usuario", schema = "smp")
@SequenceGenerator(name = "sequence", sequenceName = "smp.whosys_usuario_sequence", schema = "smp")
@NamedQueries({
    @NamedQuery(name = "WhoSysUsuario.findAll", query = "SELECT a FROM WhoSysUsuario a ORDER BY a.id ASC"),
    @NamedQuery(name = "WhoSysUsuario.findById", query = "SELECT a FROM WhoSysUsuario a WHERE a.id = :id"),
    @NamedQuery(name = "WhoSysUsuario.findByUsuarioSistema", query = "SELECT a FROM WhoSysUsuario a WHERE a.usuarioSistema = :usuarioSistema"),
    @NamedQuery(name = "WhoSysUsuario.findByWhoSys", query = "SELECT a FROM WhoSysUsuario a WHERE a.whoSys = :whoSys"),})
public class WhoSysUsuario implements Serializable, BaseEntity {

    @Id
    @GeneratedValue(generator = "sequence", strategy = GenerationType.AUTO)
    @Column(name = "id_whosys_usuario", nullable = false, unique = true)
    private Long id;

    @ManyToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "usuario_sistema")
    private UsuarioSistema usuarioSistema;

    @ManyToOne(cascade = CascadeType.PERSIST)
    @JoinColumn(name = "whoSys")
    private WhoSys whoSys;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public UsuarioSistema getUsuarioSistema() {
        return usuarioSistema;
    }

    public void setUsuarioSistema(UsuarioSistema usuarioSistema) {
        this.usuarioSistema = usuarioSistema;
    }

    public WhoSys getWhoSys() {
        return whoSys;
    }

    public void setWhoSys(WhoSys WhoSys) {
        this.whoSys = WhoSys;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 83 * hash + (this.id != null ? this.id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final WhoSysUsuario other = (WhoSysUsuario) obj;
        if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "WhoSysUsuario{" + "id=" + id + ", usuarioSistema=" + usuarioSistema + ", WhoSys=" + whoSys + '}';
    }
}
